package com.zhiyou.service.imp;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.javassist.compiler.ast.Visitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhiyou.mapper.VisitorMapper;
import com.zhiyou.model.FyVisitor;
import com.zhiyou.service.VisitorService;



@Service
public class VisitorServiceImp implements VisitorService {
	@Autowired
	VisitorMapper mapper;
	
	public void add(FyVisitor visitor) {
		mapper.add(visitor);
		
	}

	public List<FyVisitor> selectall() {
		// TODO Auto-generated method stub
		return mapper.selectall();
	}

	public FyVisitor selectByid(int visitor_id) {
		// TODO Auto-generated method stub
		return mapper.selectByid(visitor_id);
	}

	public List<FyVisitor> selectDate() {
		// TODO Auto-generated method stub
		return mapper.selectDate();
	}

	public List<FyVisitor> selectWeek() {
		// TODO Auto-generated method stub
		return mapper.selectWeek();
	}

	public List<FyVisitor> selectMonth() {
		// TODO Auto-generated method stub
		return mapper.selectMonth();
	}

	public void delete(int visitor_id) {
		mapper.delete(visitor_id);
		
		
	}

	public void ByDate() {
		mapper.ByDate();
		
	}

	public void ByMonth() {
		// TODO Auto-generated method stub
		mapper.ByMonth();
	}

	public void ByWeek() {
		// TODO Auto-generated method stub
		mapper.ByWeek();
	}
	
	//查询人数
	public Map<String, Integer> selectNum() {
		Map<String, Integer> map = new HashMap<String, Integer>();
		 Integer date = mapper.ByDate();
		 Integer week = mapper.ByWeek();
		 Integer month = mapper.ByMonth();
		 map.put("今日人数", date==null?0:date);
		 map.put("本周人数", week==null?0:week);
		 map.put("本月人数", month==null?0:month);
		return map;
	}
	//申请记录(已审批)
	public List<FyVisitor> recorded() {
		// TODO Auto-generated method stub
		return mapper.recorded();
	}
	//申请记录(未审批)
	public List<FyVisitor> record() {
		// TODO Auto-generated method stub
		return mapper.record();
	}

	public void update(FyVisitor visitor) {
		mapper.update(visitor);
		
	}

}
